<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="dialog" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{dialogHome.managed ? 'Edit' : 'Add'} Dialog</f:facet>





            <s:decorate id="createDateField" template="layout/edit.xhtml">
                <ui:define name="label">Create date</ui:define>
                <rich:calendar id="createDate"
                       required="true"
                          value="#{dialogHome.instance.createDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="updateDateField" template="layout/edit.xhtml">
                <ui:define name="label">Update date</ui:define>
                <rich:calendar id="updateDate"
                          value="#{dialogHome.instance.updateDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="deleteDateField" template="layout/edit.xhtml">
                <ui:define name="label">Delete date</ui:define>
                <rich:calendar id="deleteDate"
                          value="#{dialogHome.instance.deleteDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="lastCommentDateField" template="layout/edit.xhtml">
                <ui:define name="label">Last comment date</ui:define>
                <rich:calendar id="lastCommentDate"
                          value="#{dialogHome.instance.lastCommentDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="ownerSeenDateField" template="layout/edit.xhtml">
                <ui:define name="label">Owner seen date</ui:define>
                <rich:calendar id="ownerSeenDate"
                          value="#{dialogHome.instance.ownerSeenDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <s:decorate id="otherSeenDateField" template="layout/edit.xhtml">
                <ui:define name="label">Other seen date</ui:define>
                <rich:calendar id="otherSeenDate"
                          value="#{dialogHome.instance.otherSeenDate}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{dialogHome.persist}"
                       disabled="#{!dialogHome.wired}"
                       rendered="#{!dialogHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{dialogHome.update}"
                       rendered="#{dialogHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{dialogHome.remove}"
                      immediate="true"
                       rendered="#{dialogHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Dialog.xhtml"
                rendered="#{dialogHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty dialogFrom ? 'DialogList' : dialogFrom}.xhtml"
                rendered="#{!dialogHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Travel *" labelClass="required">
    <div class="association" id="travelParent">

        <h:outputText value="There is no travel associated with this dialog."
                   rendered="#{dialogHome.instance.travel == null}"/>

        <rich:dataTable var="_travel"
                   value="#{dialogHome.instance.travel}"
                rendered="#{dialogHome.instance.travel != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="travelTable">
            <h:column>
                <f:facet name="header">Id travel</f:facet>
                <h:outputText value="#{_travel.idTravel}"/>
            </h:column>
            <h:column>
                <f:facet name="header">City by to city id city</f:facet>
                <h:outputText value="#{_travel.cityByToCity.idCity}"/>
            </h:column>
            <h:column>
                <f:facet name="header">State by from state id state</f:facet>
                <h:outputText value="#{_travel.stateByFromState.idState}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Country by from country id country</f:facet>
                <h:outputText value="#{_travel.countryByFromCountry.idCountry}"/>
            </h:column>
            <h:column>
                <f:facet name="header">User id user</f:facet>
                <h:outputText value="#{_travel.user.idUser}"/>
            </h:column>
            <h:column>
                <f:facet name="header">State by to state id state</f:facet>
                <h:outputText value="#{_travel.stateByToState.idState}"/>
            </h:column>
            <h:column>
                <f:facet name="header">City by from city id city</f:facet>
                <h:outputText value="#{_travel.cityByFromCity.idCity}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Country by to country id country</f:facet>
                <h:outputText value="#{_travel.countryByToCountry.idCountry}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{_travel.name}"/>
            </h:column>
            <h:column>
                <f:facet name="header">From lat</f:facet>
                <h:outputText value="#{_travel.fromLat}"/>
            </h:column>
            <h:column>
                <f:facet name="header">From lon</f:facet>
                <h:outputText value="#{_travel.fromLon}"/>
            </h:column>
            <h:column>
                <f:facet name="header">To lat</f:facet>
                <h:outputText value="#{_travel.toLat}"/>
            </h:column>
            <h:column>
                <f:facet name="header">To lon</f:facet>
                <h:outputText value="#{_travel.toLon}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Distance</f:facet>
                <h:outputText value="#{_travel.distance}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Travel state</f:facet>
                <h:outputText value="#{_travel.travelState}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Calculated rate</f:facet>
                <h:outputText value="#{_travel.calculatedRate}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Create date</f:facet>
                <h:outputText value="#{_travel.createDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Modify date</f:facet>
                <h:outputText value="#{_travel.modifyDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Delete date</f:facet>
                <h:outputText value="#{_travel.deleteDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Cron expression</f:facet>
                <h:outputText value="#{_travel.cronExpression}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Monday</f:facet>
                <h:outputText value="#{_travel.monday}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Tuesday</f:facet>
                <h:outputText value="#{_travel.tuesday}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Wednesday</f:facet>
                <h:outputText value="#{_travel.wednesday}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Thursday</f:facet>
                <h:outputText value="#{_travel.thursday}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Friday</f:facet>
                <h:outputText value="#{_travel.friday}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Saturday</f:facet>
                <h:outputText value="#{_travel.saturday}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Sunday</f:facet>
                <h:outputText value="#{_travel.sunday}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Begin date</f:facet>
                <h:outputText value="#{_travel.beginDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">End date</f:facet>
                <h:outputText value="#{_travel.endDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Single day</f:facet>
                <h:outputText value="#{_travel.singleDay}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{dialogHome.instance.travel != null ? 'changeParent' : 'selectParent'}" value="#{dialogHome.instance.travel != null ? 'Change' : 'Select'} travel"
                       view="/TravelList.xhtml">
                <f:param name="from" value="DialogEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="User *" labelClass="required">
    <div class="association" id="userParent">

        <h:outputText value="There is no user associated with this dialog."
                   rendered="#{dialogHome.instance.user == null}"/>

        <rich:dataTable var="_user"
                   value="#{dialogHome.instance.user}"
                rendered="#{dialogHome.instance.user != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="userTable">
            <h:column>
                <f:facet name="header">Id user</f:facet>
                <h:outputText value="#{_user.idUser}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Login</f:facet>
                <h:outputText value="#{_user.login}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Password</f:facet>
                <h:outputText value="#{_user.password}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{_user.name}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Surname</f:facet>
                <h:outputText value="#{_user.surname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Birth date</f:facet>
                <h:outputText value="#{_user.birthDate}">
                    <s:convertDateTime type="date" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Create date</f:facet>
                <h:outputText value="#{_user.createDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Modify date</f:facet>
                <h:outputText value="#{_user.modifyDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Delete date</f:facet>
                <h:outputText value="#{_user.deleteDate}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Type</f:facet>
                <h:outputText value="#{_user.type}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Calculated rate</f:facet>
                <h:outputText value="#{_user.calculatedRate}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Enabled</f:facet>
                <h:outputText value="#{_user.enabled}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{dialogHome.instance.user != null ? 'changeParent' : 'selectParent'}" value="#{dialogHome.instance.user != null ? 'Change' : 'Select'} user"
                       view="/UserList.xhtml">
                <f:param name="from" value="DialogEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Comments">
        <h:form styleClass="association" id="commentsChildren">

            <h:outputText value="There are no comments associated with this dialog."
                       rendered="#{empty dialogHome.comments}"/>

            <rich:dataTable value="#{dialogHome.comments}"
                           var="_comment"
                      rendered="#{not empty dialogHome.comments}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="commentsTable">
                <rich:column sortBy="#{_comment.idComment}">
                    <f:facet name="header">Id comment</f:facet>
                    <h:outputText value="#{_comment.idComment}"/>
                </rich:column>
                <rich:column sortBy="#{_comment.msg}">
                    <f:facet name="header">Msg</f:facet>
                    <h:outputText value="#{_comment.msg}"/>
                </rich:column>
                <rich:column sortBy="#{_comment.createDate}">
                    <f:facet name="header">Create date</f:facet>
                    <h:outputText value="#{_comment.createDate}">
                        <s:convertDateTime type="both" dateStyle="short"/>
                    </h:outputText>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{dialogHome.managed}" id="comments">
        <div class="actionButtons">
            <s:button id="addcomment"
                   value="Add comment"
                    view="/CommentEdit.xhtml"
             propagation="none">
                 <f:param name="dialogIdDialog"
                         value="#{dialogHome.instance.idDialog}"/>
                 <f:param name="commentFrom" value="Dialog"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
